/******************************************
@Description:监管可视化-卡包消费记录
@Time : 2020/12/1 15:23
@Author :lixiaojun
交换机=consume.relationlogid

*******************************************/
package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	dataVisualization2 "git.900sui.cn/kc/rpcinterface/client/dataVisualization"
	"git.900sui.cn/kc/rpcinterface/interface/dataVisualization"
	"github.com/streadway/amqp"
	"strconv"
)

func main() {
	rpcDataVisualization:=new(dataVisualization2.CardPackageConsumeLog).Init()
	defer rpcDataVisualization.Close()

	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("dataVisualization.log.cardPackageConsumeLog"))

	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("dataVisualization.queue.cardPackageConsumeLog"), func(msg amqp.Delivery) {
		args :=dataVisualization.ArgsSetCardPackageConsumeLog{}
		args.RelationLogId,_=strconv.Atoi(string(msg.Body))
		var reply bool
		if err:=rpcDataVisualization.SetCardPackageConsumeLog(context.Background(),&args,&reply);err!=nil{
			utils.Logerr.Printf("消费成功,监管可视化-卡包消费记录任务调用失败，消费记录RelationLogId：%d err:%s\n",args.RelationLogId,err.Error())
			return
		}

	})

	if err != nil {
		utils.Logerr.Printf("消费成功异步回调任务错误，err:%s\n",err.Error())
	}
}

